<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\controller;

/**
 * 前端首页控制器
 */
class Index extends IndexBase
{
    
    // 首页
    public function index()
    {
        
        $where = [];
        
        $this->assign('article_list', $this->logicArticle->getArticleListForView(['category_id' =>'1'], 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
        $this->assign('healthroomNumber',count($this->logicHealthroom->getHealthroomListForCount()));//小屋数量
        $this->assign('expertNumber',$this->logicExpertinroom->getExperListForCount());//专家数量
        $this->assign('hospitalNumber',$this->logicHealthroom->getHospitalListForCount());//拥有小屋医院数量
        $this->assign('personNumber',$this->logicActivity->getPersonListForCount());//拥有小屋医院数量

        //区县小屋数量对比
        $this->assign('clist',$this->logicHealthroom->getHealthroomCount());
        //全市小屋增长率
        $this->assign('ilist',$this->logicHealthroom->getHealthroomIncrease());
        //区县小屋服务水平对比
        $this->assign('slist',$this->logicHealthroom->getHealthroomServiceLevel());
        //网站标题
        $this->assign('title',"邯郸市健康小屋");
        //
        ////
        $this->assign('activityDetail_list', $this->logicActivityDetail->getDetailList($where, true));

        return $this->fetch('index');
    }
    
    // 详情
   public function a_details($id = 0)
    {
        
        $where = [];
        
        !empty((int)$id) && $where['a.id'] = $id;
        
        $data = $this->logicArticle->getArticleInfo($where);
        $this->assign('title',"邯郸市健康小屋");
        $data['name'] = html_entity_decode($data['name']);
        $data['describe'] = html_entity_decode($data['describe']);
        $data['content'] = html_entity_decode($data['content']);
        $this->assign('article_info', $data);
        
        $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
        
        return $this->fetch('a_details');
    }
    public function details($id = 0)
    {
        
        $where = [];
        
        !empty((int)$id) && $where['ad.id'] = $id; 
        $this->assign('title',"邯郸市健康小屋");
        $info = $this->logicActivityDetail->getActivityDetailInfo(['id' =>$id]);
        $info['intro'] = html_entity_decode($info['intro']);
        $this->assign('activityDetail_list', $info);
        return $this->fetch('details');
    }

 /**
     * 小屋情况
  
    /**
     * 增加返回地图的方法
     */
    public function map()
    {
        // $filename = "../public/static/images/130400.json";//文件相对路径  
        // $map = file_get_contents($filename);//读取json内容 
        // $this->assign('map',$map);
      return $this->fetch('map');
    }

        /**
     * 增加打印的方法
     */
    public function printit()
    {

      return $this->fetch('printit');
    }

    /**
     * 前台健康小屋列表
     */
   public function healthroomList($room_id)
    {
       $this->assign('title',"邯郸市健康小屋");
       $this->assign('healthroom_list', $this->logicActivityDetail->getDetailList(['h.room_id'=>$room_id], true));
        $info = $this->logicHealthroom->getHealthroomInfo(['room_id'=>$room_id], true);
        $info['description'] = html_entity_decode($info['description']);
        $this->assign('healthroom_description', $info);
        $this->assign('healthroom_name',$info['name']);

        return $this->fetch('healthroom_list');

    }
    /**
     * 专家风采，首页栏目
     */
    public function expertList()
    {
        $this->assign('title',"邯郸市健康小屋");
        $list=$this->logicArticle->getArticleListForView(['category_id'=>'2']);

        $this->assign('article_list',$list);
        return $this->fetch('expert_list');
    }
        /**
     * 本周活动,列表
     */
    public function weekday()
    {
        
        $where = [];
        $this->assign('title',"邯郸市健康小屋");
        $this->assign('activityDetail_list', $this->logicActivityDetail->getDetailList($where, true));
        return $this->fetch('weekday');
    }
     /**
     * 下周预告,列表
     */
    public function nextweek()
    {
        
        $where = [];
        $this->assign('title',"邯郸市健康小屋");
        $this->assign('activity_list', $this->logicActivity->getActivityList($where, true));
        return $this->fetch('nextweek');
    }
}
